import { ref, shallowRef } from 'vue'
import type { RegisteredComponent } from '@/utils/dynamicLoader/componentLoader'
import { loadPageComponents } from '@/utils/dynamicLoader/componentLoader'

const registeredComponents = shallowRef<RegisteredComponent[]>([])

export async function initializeComponents() {
  registeredComponents.value = await loadPageComponents()
}

export function getRegisteredComponents() {
  return registeredComponents.value
}

export function getComponentByType(type: string) {
  return registeredComponents.value.find(comp => comp.type === type)
}

// 初始化组件
initializeComponents() 